package com.edu.employee.controller.test;

import com.edu.commons.R;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @ProjectName: summer-project
 * @Titile: HelleController
 * @Author: Lucky
 * @Description: TODO
 */
//@RestController
//@Controller
//@RequestMapping("/api/test") // /api/test
@Slf4j
//@ResponseBody
public class HelleController {

    @GetMapping("")
    public R<Void> test(){
      log.info("正在测试");
      //throw new ServiceException(ServiceCode.ERROR_UN_KNOW,"测试异常处理");
        int a = 10 / 0;
      return R.ok("测试成功");
    }

    @RequestMapping("/api/hello")
    @ResponseBody //标注这个方法返回的是数据
    public String hello(){
        return "index";
    }

    @GetMapping("/api/user")
    //@ResponseBody
    public Object get(){
        User user = new User();
        user.setId(1001);
        user.setName("zhangsan");
        return user;
    }
    @Data
    class User{
        private Integer id;
        private String name;
    }

    @GetMapping("/api/user2")
    //@ResponseBody
    public R<User> get2(){
        User user = new User();
        user.setId(1001);
        user.setName("zhangsan");
        return R.ok("获取信息成功",user);
    }



}
